package Controller.GoodsCategory;


import Service.GoodsCategoryService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Map;

@WebServlet(name = "listGoodsCategory", value = "/ListGoodsCategory")
public class ListGoodsCategory extends HttpServlet {
    private GoodsCategoryService goodsCategoryService = new GoodsCategoryService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String pageNum = request.getParameter("pageNum");
        try{
            Map<String,Object> map = goodsCategoryService.selectCategoryByPage(pageNum==null?1:Integer.valueOf(pageNum));
            request.setAttribute("map",map);
            request.getRequestDispatcher("/ListGoodsCategory.jsp").forward(request,response);
        }catch (SQLException e){
            System.out.println("sql异常");
            e.printStackTrace();
        }
    }
}